import { request } from '@/utils/request'
import type { Commodity } from '@/types/commodity'
import type {
  FindSubCategoryFilterType,
  findSubCategoryGoodsType,
  FindTopCategoryType
} from '@/types/category'
/**
 * 获取首页头部分类数据
 */
export const findAllCategory = () => {
  return request<Commodity[]>('/home/category/head')
}

/**
 * 获取单个顶级分类信息
 */
export const findTopCategory = (id: string) => {
  return request<FindTopCategoryType>('/category', 'get', { id })
}

/**
 * 获取二级分类筛选条件数据
 */
export const findSubCategoryFilter = (id: string) => {
  return request<FindSubCategoryFilterType>(
    '/category/sub/filter',
    'get',
    { id }
  )
}

/**
 * 获取分类下的商品（带筛选条件）
 */
export const findSubCategoryGoods = (params) => {
  return request<findSubCategoryGoodsType>(
    '/category/goods/temporary',
    'post',
    params
  )
}
